//
//  XQPromptViewController.m
//  XQClock
//
//  Created by 孙强 on 2024/8/9.
//

#import "XQPromptViewController.h"
#import "XQPromptTableViewCell.h"


@interface XQPromptViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) NSMutableArray *dataArr;

@end

@implementation XQPromptViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, GJScreenW, GJScreenH)];

    
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0.0,0,GJScreenW,GJScreenH);
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)colorFromHexString(@"F2E9FF").CGColor, (__bridge id)colorFromHexStringWithAlpha(@"FFEFE6", 1).CGColor];
    gl.locations = @[@(0), @(0.5f)];
    [backView.layer addSublayer:gl];
    [self.view addSubview:backView];
    
    [self createTableview];
    
}


- (void)createTableview
{
//    @"How to add
//    desktop widgets?"
    
    _dataArr = [NSMutableArray arrayWithObjects:@"Press and hold the empty part of the desktop until the app icons jiggle",@"Click the '+' button at the top left corner",@"Find and select the 'Clock' widget, choose the size you need, and click the 'Add widget' button.",@"If you can't find the clock when adding widgets, please restart your phone once, open the Clock app once, and then try adding it again. If you encounter blacked-out widgets, restarting the phone can restore them.", nil];
        
    
    _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, GJScreenW, GJScreenH) style:UITableViewStylePlain];
    _myTableView.backgroundColor =UIColor.clearColor;
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.myTableView.showsVerticalScrollIndicator = NO;
    self.myTableView.alwaysBounceVertical = NO;
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    [self.view addSubview:_myTableView];
    _myTableView.estimatedRowHeight = UITableViewAutomaticDimension;
    [_myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(NavigationHeight);
        make.bottom.equalTo(0);
    }];
    
    [self createHeaderView];
    
}
- (void)createHeaderView{
    
   UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, GJScreenW,  398*GJHeight - NavigationHeight)];
    _myTableView.tableHeaderView = headerView;
    headerView.backgroundColor = UIColor.clearColor;
    
    
    
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
        return _dataArr.count;
 
            
    
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return UITableViewAutomaticDimension;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    @weakify(self);
    static NSString *identifier = @"XQPromptTableViewCell";
    XQPromptTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[XQPromptTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }

    cell.contentLabel.text = [_dataArr objectAtIndex:indexPath.row];
    
    return cell;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
        
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
